package cn.wanxue.controller;

import cn.wanxue.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;


/**
 * @author zenghu
 * @date 2018/5/15 17:25
 */
@Controller
public class IndexController {

    @Autowired CommonService commonService;

    @RequestMapping("/")
    public String defaultIndex(){
        return "redirect:/index/index";
    }

    @RequestMapping("/index/index")
    public String index(String name,Model model) {
        List<Map<String,Object>> list=commonService.customSqlQuery("select * from user");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        model.addAttribute("name",name);
        return "/index/index";
    }

}
